<template>
	<view class="confirmOrder">
        <SRV-topbar title="提交订单" :isLeft="true"></SRV-topbar>
		<view class="topType">
			<view :class="formData.shipping_type==2?'item sel':'item'" @click="setShippingType(2)">
				<text>自提</text>
				<view :class="formData.shipping_type==2?'heng':''"></view>
			</view>
			<view :class="formData.shipping_type==1?'item sel':'item'" @click="setShippingType(1)">
				<text>物流配送</text>
				<view :class="formData.shipping_type==1?'heng':''"></view>
			</view>
		</view>
		<view class="top" v-if="formData.shipping_type==1">
			<view class="noaddress" @click="jump('addOreditAddress', 'formType=1')" v-if="address.id == 0">
				<image :src="'https://hdsq.aoorange.cn/attachment/xcx/icon/xinjiandizhi.png'" mode="widthFix"></image>
				<text>+新建地址</text>
			</view>
			<view class="address" @click="jump('address', 'formType=1')" v-else>
				<image :src="'https://hdsq.aoorange.cn/attachment/xcx/icon/address.png'" mode="widthFix"></image>
				<view class="right">
					<view class="txt">
						<text>收货人：{{address.realname}}</text>
						<text>{{address.mobile}}</text>
					</view>
					<view class="txt1">
						收货地址：{{address.address}}
					</view>
					<view class="jt"></view>
				</view>
			</view>
		</view>
		<view class="top" v-if="formData.shipping_type==2">
			<view class="pickup" v-if="pickupList.length > 0" v-for="(pickup, index2) in pickupList" :key="index2">
				<view :class="formData.pickup_id == pickup.id ?'check':'nocheck'" @click="checkPickup(pickup.id)">
				</view>
				<view class="right" style="margin-left: 20rpx;">
					<view class="txt">
						<text>{{pickup.title}}</text>
						<text>{{pickup.mobile}}</text>
					</view>
					<view class="txt1">
						{{pickup.address}}
					</view>
				</view>
			</view>
		</view>
		<view class="main" v-for="(merchant,index) in merchantList" :key="index">
			<view class="goods_top">
				<view class="left" @click="jump(merchant.jumpType, merchant.jumpLink)">
					<image :src="merchant.logo" mode="aspectFill"></image>
					<text>{{merchant.title}}</text>
				</view>
			</view>
			<view v-for="(item,kkkk) in merchant.productList" :key="kkkk">
				<view class="goods">
					<image :src="item.product_img" mode="aspectFill"></image>
					<view class="right">
						<view class="right-p">
							<span v-if="item.reductionName != ''" style="background: rgba(235, 89, 56, 1); color: #ffffff; padding: 0 10rpx;margin-right: 10rpx;">{{item.reductionName}}</span>
							{{item.product_name}}
						</view>
						<text>{{item.sku_name}}</text>
						<view class="size">
							<text>{{item.showPrice}} x {{item.number}} <text v-if="item.originalPrice != item.showPrice" style="text-decoration: line-through;text-decoration-color:red">（{{item.originalPrice}}）</text></text>
							
                            <text class="pic1">{{item.totalMoney}}</text>
						</view>
						<view v-if="item.numberActivity != '' && item.number > 1">{{item.numberActivity}}</view>
					</view>
				</view>
			</view>
            <view class="line">
                <text>商品数量</text>
                <text>{{merchant.num}} 件</text>
            </view>
			<view class="line" v-if="merchant.deductMoney > 0">
			    <text>减免金额</text>
			    <text>-¥{{merchant.deductMoney}}</text>
			</view>
            <view class="line">
                <text>商品总金额</text>
                <text>¥{{merchant.goodsMoney}}</text>
            </view>
            <view class="line" v-if="formData.shipping_type==1">
            	<text>快递方式</text>
            	<view class="right">
            		<picker v-if="merchant.shippingList.length > 0" @change="bindDeliveryChange" :value="selShipping[merchant.id].itemId" :range="merchant.shippingList" range-key="itemName" :data-id="merchant.id">
            			<view class="item">{{selShipping[merchant.id].itemName}}</view>
            		</picker>
            		<view class="jt"></view>
            	</view>
            </view>
            <view class="line" v-if="formData.shipping_type==1 && selShipping[merchant.id].isShow">
                <text>快递费用</text>
                <text>{{selShipping[merchant.id].money > 0 ? '+ ¥'+selShipping[merchant.id].money : '包邮'}}</text>
            </view>
			<view class="line" v-if="merchant.couponList.length > 0">
				<text>优惠券</text>
				<view class="right">
					<picker v-if="merchant.couponList.length > 0" @change="bindCouponChange" :value="selCoupon[merchant.id].itemId" :range="merchant.couponList" range-key="itemName" :data-id="merchant.id">
						<view class="item">{{selCoupon[merchant.id].itemName}}</view>
					</picker>
					<view class="jt"></view>
				</view>
			</view>
            <view class="line" v-if="selCoupon[merchant.id].isShow">
                <text>优惠金额</text>
                <text>{{'- ¥'+selCoupon[merchant.id].money}}</text>
            </view>
            <view class="line" v-if="payInfo.use_merchant_money > 0" @click="selMerchantMoney()">
                <view style="display: flex;">
                    <view :class="payData.is_use_merchant_money ?'selRadio':'noRadio'"></view>
                    <view>商家余额（{{payInfo.merchant_money}}）</view>
                </view>
                <view><text>-￥{{payInfo.use_merchant_money}}</text></view>
                <view class="tipTxt">使用商家余额支付将不能获取商家让利及平台补贴</view>
            </view>
            <view class="line" v-if="merchant.sjrlState && merchant.sjrlInto != ''" @click="selRewardType(1)">
                <view style="display: flex;">
                    <view :class="formData.reward_type == 1 ?'selRadio':'noRadio'"></view>
                    <view>{{merchant.sjrlTitle}}</view>
                </view>
                <text>-{{merchant.sjrlInto}}</text>
            </view>
            <view class="line" v-if="merchant.ptbtInfo != ''" @click="selRewardType(2)">
                <view style="display: flex;">
                    <view :class="formData.reward_type == 2 ?'selRadio':'noRadio'"></view>
                    <view>{{merchant.ptbtTitle}}</view>
                </view>
                <text>{{merchant.ptbtInfo}}</text>
            </view>
			<view class="line">
				<text>最终金额</text>
				<text>¥{{merchant.payMoney}}</text>
			</view>
            <view class="common">
            	<text>买家留言</text>
            	<textarea placeholder-style="color:rgba(66,81,114,0.5);" value="" placeholder="留言备注..."
            		v-model="remarkList[merchant.id]" />
            </view>
		</view>
		<view class="bottom" :style="'height:' + bottomHeight + 'rpx;'">
			<text>共{{payInfo.num}}件</text>
			<view class="pic1">
				<text>合计</text>
				<text>￥{{payInfo.pay_money}}</text>
			</view>
			<view class="btn" @click="createOrder()">提交订单</view>
		</view>
		<uni-popup ref="popup" type="bottom">
			<scroll-view class="pay_type" scroll-y>
				<image @click="close()" class="close" src="https://hdsq.aoorange.cn/attachment/xcx/icon/close1.png"
					mode="aspectFill"></image>
				<view class="title">选择支付方式</view>
				<view class="paypir">
					<text>应付金额</text>
					<text>￥{{payInfo.pay_money}}</text>
				</view>
				<view class="line2" v-if="payInfo.use_hdq > 0 && isSelPlatformType" @click="setUseOther(1)">
					<text>互动券{{payInfo.use_hdq}}个抵扣金额￥{{payInfo.use_hdq}}</text>
					<view :class="payData.is_use_hdq == 1 ?'check':'nocheck'"></view>
				</view>
                <view class="line2" v-if="payInfo.use_judge > 0 && isSelPlatformType" @click="setUseOther(3)">
                	<text>品鉴金{{payInfo.use_judge}}抵扣金额￥{{payInfo.use_judge}}</text>
                	<view :class="payData.is_use_judge == 1 ?'check':'nocheck'"></view>
                </view>
                <view class="line2" v-if="payInfo.use_three > 0 && isSelPlatformType" @click="setUseOther(5)">
                	<text>平台囤陈三{{payInfo.use_three}}抵扣金额￥{{payInfo.use_three}}</text>
                	<view :class="payData.is_use_three == 1 ?'check':'nocheck'"></view>
                </view>
                <view class="line2" v-if="payInfo.use_one > 0 && isSelPlatformType" @click="setUseOther(7)">
                	<text>平台囤陈一{{payInfo.use_one}}抵扣金额￥{{payInfo.use_one}}</text>
                	<view :class="payData.is_use_one == 1 ?'check':'nocheck'"></view>
                </view>
				<view class="line2" v-if="payInfo.use_merchant_one > 0 && isSelPlatformType" @click="setUseOther(9)">
					<text>商家囤陈一{{payInfo.use_merchant_one}}抵扣金额￥{{payInfo.use_merchant_one}}</text>
					<view :class="payData.is_use_merchant_one == 1 ?'check':'nocheck'"></view>
				</view>
				<view class="line2" v-if="payInfo.pay_money > 0 && isSelPlatformType" @click="selPayType(5)">
					<text>余额支付 - 当前余额：{{payInfo.user_money}}</text>
					<view :class="payData.payment_type == 5 ?'sel':'nosel'" v-if="Number(payInfo.user_money) >= Number(payInfo.pay_money)"></view>
					<text v-else @click="jump('online_recharge')">余额不足</text>
				</view>
				<view class="line2" v-if="payInfo.pay_money > 0 && isSelPlatformType" @click="selPayType(1)">
					<text>在线微信支付</text>
					<view :class="payData.payment_type == 1 ?'sel':'nosel'"></view>
				</view>
				<view :style="'height:' + bottomHeight + 'rpx;'" class="pay_bot" @click="subPay()">确认支付</view>
			</scroll-view>
		</uni-popup>
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
    import commonPay from '../../static/commonPay.js';
    import {Base64} from '../../static/base64.min.js';
	var _self;
	export default {
		data() {
			return {
				formData: {
					appkey: uni.getStorageSync('appkey'),
					'access-token': uni.getStorageSync('access-token'),
                    merchant_id: 0,
					type: '', //提交类型 cart 购物车 buy_now 立即购买
					data: '', //购物车ID组合
					sku_id: '', //立即购买的商品SKUID
					num: 1, //立即购买的数量
					storeType: 1, //立即购买的来源 1：品鉴 2：云仓
					shipping_type: 2, //配送类型 1：物流配送 2：自提
					pickup_id: 0, //自提ID
					address_id: 0, //收货地址
					is_npm: 0, //是否赠送积分
					reward_type: 0, //奖励类型
					couponIds: '', //使用优惠券组合 店铺ID:优惠券ID;
					companyIds: '', //快递方式组合 店铺ID:优惠券ID;
					remark: '', //备注组合
				},
                account: {user_money: 0, user_integral: 0, judge_cash: 0},
                address: {id: 0},
                merchantList: [],
                pickupList: [],
				shippingList: [],
                selShipping: [],
				couponList: [],
                selCoupon: [],
                remarkList: [],
                isSelPlatformType: true,
                payData: {
                	appkey: uni.getStorageSync('appkey'),
                	'access-token': uni.getStorageSync('access-token'),
                	pay_type: '',
                    drawType: '',
                    reward_type: 0,
                	pay_id: 0,
                	is_use_hdq: 0,
                    is_use_judge: 0,
                    is_use_one: 0,
                    is_use_three: 0,
					is_use_merchant_one: 0,
					is_use_merchant_money: 0,
                	payment_type: 1,
                    jumpFile: '',
                },
                payInfo: {
                    num: 0,
					total_money: 0,
                    pay_money : 0,
                    user_money: 0,
                    sjrl: 0,
                    user_hdq: 0,
                    judge_cash: 0,
                    check_use_judge: false,
                    use_judge: 0,
                    check_use_hdq: false,
                    use_hdq: 0,
                    use_judge: 0,
                    check_use_one: false,
                    use_one: 0,
                    check_merchant_one: false,
                    use_merchant_one: 0,
                    check_use_three: false,
                    use_three: 0,
                },
				optionsParam: '',
				isSub: false,
				
				bottomHeight: 110, /* 底部按钮高度，避免iPhonex导航黑条 */
			}
		},
		methods: {
			resetAddress(v) {
				_self.formData.address_id = v.id;
				_self.previewOrder();
			},
			numFilter(value) {
				let tempVal = parseFloat(value).toFixed(3);
				let realVal = tempVal.substring(0, tempVal.length - 1);
				return realVal;
			},
			checkPickup(pid) {
				_self.formData.pickup_id = pid;
			},
			setShippingType(type) {
				_self.formData.shipping_type = type;
			},
            selMerchantMoney() {
                _self.payInfo.pay_money = JSON.parse(JSON.stringify(_self.payInfo.total_money));
                _self.payData.is_use_merchant_money = _self.payData.is_use_merchant_money == 1 ? 0 : 1;
				_self.isSelPlatformType = true;
                if(_self.payData.is_use_merchant_money) {
                    _self.formData.reward_type = 0;
					console.info(_self.merchantList[0].payMoney + ' - ' + _self.payInfo.use_merchant_money);
					_self.merchantList[0].payMoney = _self.numFilter(Number(_self.merchantList[0].payMoney) - Number(_self.payInfo.use_merchant_money));
					console.info(" = " + _self.merchantList[0].payMoney);
                    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_merchant_money));
					_self.isSelPlatformType = _self.payInfo.pay_money > 0;
					if(_self.payInfo.pay_money <= 0 && _self.payData.payment_type != 5) {
						_self.payData.payment_type = 5;
					}
                    return ;
                }
				console.info(_self.merchantList[0].payMoney + ' + ' + _self.payInfo.use_merchant_money);
				_self.merchantList[0].payMoney = _self.numFilter(Number(_self.merchantList[0].payMoney) + Number(_self.payInfo.use_merchant_money));
				console.info(" = " + _self.merchantList[0].payMoney);
                if(_self.merchantList[0].sjrlInto != '') {
                    _self.formData.reward_type = 1;
                }
                if(_self.merchantList[0].ptbtInfo != '') {
                    _self.formData.reward_type = 2;
                }
            },
            selRewardType(type) {
                if(_self.payData.is_use_merchant_money) {
                    _self.formData.reward_type = 0;
                    return ;
                }
                _self.payInfo.pay_money = JSON.parse(JSON.stringify(_self.payInfo.total_money));
                _self.formData.reward_type = type;
                if(_self.formData.reward_type == 1) {
                    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.sjrl));
                } else {
                    // _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) + Number(_self.payInfo.sjrl));
                }
            },
			setUseOther(type) {
				if (type == 1) {
					_self.payData.is_use_hdq = _self.payData.is_use_hdq == 1 ? 0 : 1;
				} 
                if (type == 3){
					_self.payData.is_use_judge = _self.payData.is_use_judge == 1 ? 0 : 1;
				}
                if (type == 5){
                	_self.payData.is_use_three = _self.payData.is_use_three == 1 ? 0 : 1;
                }
                if (type == 7){
                	_self.payData.is_use_one = _self.payData.is_use_one == 1 ? 0 : 1;
					_self.payData.is_use_merchant_one = 0;
                }
				if (type == 9){
					_self.payData.is_use_one = 0;
					_self.payData.is_use_merchant_one = _self.payData.is_use_merchant_one == 1 ? 0 : 1;
				}
                
                _self.payInfo.pay_money = JSON.parse(JSON.stringify(_self.payInfo.total_money));
				if(_self.payData.is_use_merchant_money == 1) { 
					_self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_merchant_money));
				}
                if(_self.payData.is_use_hdq == 1) {
                    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_hdq));
                }
                if(_self.payData.is_use_judge == 1) {
                    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_judge));
                }
                if(_self.payData.is_use_three == 1) {
                    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_three));
                }
                if(_self.payData.is_use_one == 1) {
                    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_one));
                }
				if(_self.payData.is_use_merchant_one == 1) {
				    _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_merchant_one));
				}
				if(_self.payInfo.pay_money <= 0) {
					_self.payInfo.pay_money = 0.00;
				    _self.payData.payment_type = _self.payData.payment_type != 5 ? 5 : _self.payData.payment_type;
				}
			},
			previewOrder() { 
				uni.showLoading({
					title: '提交中···',
					mask: true
				});
				serve.request({
					url: '/store/order/preview',
					data: _self.formData,
                    v: '/v3',
				}).then(res => {
					uni.hideLoading();
					if (res.code != 200) {
						uni.showToast({
							title: res.message,
							icon: 'none',
							success: function() {
								setTimeout(function() {
									common.jump(res.code == 199 ? 'login' : 'return_one', 0);
									return;
								}, 2000)
							}
						});
						return;
					}
					_self.account = res.data.account;
                    _self.payInfo.user_money = _self.account.user_money;
                    _self.payInfo.sjrl = _self.account.sjrl;
                    _self.payInfo.use_hdq = _self.account.use_hdq;
                    _self.payInfo.use_judge = _self.account.use_judge;
                    _self.payInfo.use_three = _self.account.use_three;
                    _self.payInfo.use_one = _self.account.use_one;
					_self.payInfo.use_merchant_one = _self.account.use_merchant_one;
                    _self.payInfo.use_merchant_money = _self.account.use_merchant_money;
                    _self.payInfo.merchant_money = _self.account.merchant_money;
                    _self.payData.is_use_merchant_money = 0; //Number(_self.payInfo.use_merchant_money) > 0 ? 1 : 0;
                    _self.address = res.data.address;
					_self.pickupList = res.data.pickupList;
                    _self.merchantList = res.data.merchantList;
                    _self.remarkList = [];
                    _self.selCoupon = [];
                    _self.selShipping = [];
                    let temp = {isShow: false};
                    _self.merchantList.forEach((i, k) => {
                        _self.remarkList[i.id] = '';
                        // _self.push(_self.remarkList, i.id, '');
                        if(i.shippingList.length > 0) {
							_self.shippingList[i.id] = i.shippingList;
                            _self.selShipping[i.id] = i.shippingList[0];
                            _self.$set(_self.selShipping[i.id], 'isShow', true);
                        } else {
                            _self.selShipping[i.id] = temp;
                        }
                        if(i.couponList.length > 0) {
							_self.couponList[i.id] = i.couponList;
                            _self.selCoupon[i.id] = i.couponList[0];
                            _self.$set(_self.selCoupon[i.id], 'isShow', true);
                        } else {
                            _self.selCoupon[i.id] = temp;
                        }
                        _self.payInfo.num = Number(_self.payInfo.num) + Number(i.num);
                        _self.payInfo.total_money = Number(_self.payInfo.total_money) + Number(i.payMoney);
                        _self.payInfo.pay_money = JSON.parse(JSON.stringify(_self.payInfo.total_money));
                        if(_self.payData.is_use_merchant_money) {
                            _self.formData.reward_type = 0;
                            _self.payInfo.pay_money = _self.numFilter(Number(_self.payInfo.pay_money) - Number(_self.payInfo.use_merchant_money));
                        } else {
                            if(i.sjrlInto != '') {
                                _self.formData.reward_type = 1;
                            }
                            if(i.ptbtInfo != '') {
                                _self.formData.reward_type = 2;
                            }
                        }
                    });
					// _self.formData.pickup_id = _self.pickupList.length > 0 ? _self.pickupList[0].id : 0;
					_self.formData.address_id = _self.address.id;
				});
			},
			bindDeliveryChange: function(e) {
				let merchantId = e.target.dataset.id;
				let key = e.detail.value;
				let sl = _self.shippingList[merchantId];
				_self.selShipping[merchantId] = sl[key];
				_self.$set(_self.selShipping[merchantId], 'isShow', true);
				_self.$forceUpdate();
			},
			bindCouponChange: function(e) {
				let merchantId = e.target.dataset.id;
				let key = e.detail.value;
				let cl = _self.couponList[merchantId];
				_self.selCoupon[merchantId] = cl[key];
				_self.$set(_self.selCoupon[merchantId], 'isShow', true);
				_self.$forceUpdate();
			},
			close() {
				_self.$refs.popup.close();
				_self.payData.is_use_hdq = 0;
				_self.payData.is_use_judge = 0;
				_self.payData.is_use_three = 0;
				_self.payData.is_use_one = 0;
				_self.payData.is_use_merchant_one = 0;
				_self.payData.payment_type = 5;
				_self.setUseOther();
			},
			createOrder() {
				if (_self.formData.shipping_type == 1) {
					if (_self.formData.address_id == 0) {
						uni.showToast({
							title: "请选择收货地址",
							icon: 'none'
						})
						return;
					}
				} else {
                    if (_self.formData.pickup_id == 0) {
                    	uni.showToast({
                    		title: "请选择自提店铺",
                    		icon: 'none'
                    	})
                    	return;
                    }
                }
                if(_self.formData.storeType == 11) {
                    _self.subPay();
                    return ;
                }
				if(_self.payInfo.pay_money > 0) {
					_self.$refs.popup.open();
				} else {
					_self.subPay();
				}
				return;
			},
			subPay() {
				if (_self.payData.pay_id != 0) {
					commonPay.payFun(_self.payData, _self.payData.jumpFile);
					return;
				}
				uni.showLoading({
					title: '提交中···',
					mask: true
				});
				let selShippingStr = '';
                if(_self.formData.shipping_type == 1) {
                    _self.selShipping.forEach((v, k) => {
                    	selShippingStr += k + ':' + v.itemId + ';';
                    });
                }
				let selCouponStr = '';
				_self.selCoupon.forEach((v, k) => {
                    if(v.isShow) {
                        selCouponStr += k + ':' + v.itemId + ';';
                    }
				});
				let remarkStr = '';
				_self.remarkList.forEach((v, k) => {
					remarkStr += k + ':' + v + ';';
				});
				_self.formData.companyIds = selShippingStr;
				_self.formData.couponIds = selCouponStr;
				_self.formData.remark = Base64.encode(remarkStr);
                _self.payData.reward_type = _self.formData.reward_type;
				serve.request({
					url: '/store/order/create',
					data: _self.formData,
                    v: '/v3',
				}).then(res => {
                    uni.showToast({
                    	title: res.message,
                    	icon: 'none'
                    });
					if (res.code == 200) {
						uni.hideLoading();
                        if(res.data.isPay == 1) {
                            _self.payData.pay_type = res.data.pay_type;
                            _self.payData.pay_id = res.data.pay_id;
                            _self.payData.jumpFile = res.data.jumpFile;
                            commonPay.payFun(_self.payData, _self.payData.jumpFile);
                        }
						else {
                            common.jump('appoint_view', res.data.jumpFile);
                        }
                        return;
					}
				});
			},
			selPayType(payType) {
				if (payType == 5 && Number(_self.payInfo.user_money) < Number(_self.payInfo.pay_money)) {
					return;
				}
				_self.payData.payment_type = payType;
			},
			jump(jump_type, jump_link) {
				common.jump(jump_type, jump_link);
			},
		},
		onLoad(options) {
			_self = this;
			if (uni.getSystemInfoSync().safeAreaInsets.top > 20) {
				_self.bottomHeight = 150;
			}
			_self.formData.type = options.type;
            _self.formData.address_id = options.address_id || 0;
            _self.formData.merchant_id = options.merchant_id || 0;
            _self.formData.shipping_type = _self.formData.address_id > 0 ? 1 : 2;
			let paramStr = 'type=' + options.type;
			if (_self.formData.type == 'buy_now') {
				_self.formData.sku_id = options.sku_id;
				_self.formData.num = options.num;
				_self.formData.storeType = options.storeType;
			} else if (_self.formData.type == 'cart') {
				_self.formData.data = options.data;
				_self.formData.storeType = 2;
            } else if (_self.formData.type == 'level_apply') {
            	_self.formData.data = options.data;
                _self.formData.drawType = options.drawType;
            	_self.formData.storeType = 10;
            } else if (_self.formData.type == 'level_gift') {
                _self.formData.data = options.data;
                _self.formData.storeType = 11;
			} else {
                uni.showToast({
                    title: "错误的访问方式",
                    icon: 'none',
                    success() {
                        setTimeout(function() {
                            common.jump('return_one')
                        }, 2000)
                    }
                });
            }
			_self.optionsParam = paramStr;
			_self.formData.address_id = options.address_id || 0;
		},
		onShow() {
			_self.previewOrder();
		},
		onPullDownRefresh() {
			_self.payInfo = {
                    num: 0,
					total_money: 0,
                    pay_money : 0,
                    user_money: 0,
                    sjrl: 0,
                    user_hdq: 0,
                    judge_cash: 0,
                    check_use_judge: false,
                    use_judge: 0,
                    check_use_hdq: false,
                    use_hdq: 0,
                    use_judge: 0,
                    check_use_one: false,
                    use_one: 0,
                    check_use_three: false,
                    use_three: 0,
                };
			_self.previewOrder();
		}
	}
</script>

<style scoped lang="scss">
	@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
		.confirmOrder {
			padding-bottom: 124upx !important;

			.bottom {
				padding-bottom: 12px !important;
			}
		}
	}

	.confirmOrder {
		padding-bottom: 100upx;

		.bottom {
			position: fixed;
			z-index: 100;
			width: 100%;
			bottom: 0upx;
			border-top: 1upx rgba(235, 236, 240, 1) solid;
			align-items: center;
			display: flex;
			z-index: 10;
			box-sizing: border-box;
			padding-bottom: env(safe-area-inset-bottom);
			height: 100upx;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px 1px 0px 0upx rgba(235, 236, 240, 1);
			padding-left: 30upx;
			font-size: 24upx;
			color: rgba(60, 72, 104, 0.5);

			.pic1 {
				font-size: 20upx;
				margin-left: 100upx;
				color: rgba(60, 72, 104, 0.5);

				text:last-child {
					font-size: 28upx;
					color: #EB5938;
					margin-left: 10upx;
				}
			}

			.btn {
				position: absolute;
				top: 0;
				height: 100rpx;
				width: 300upx;
				background: #EB5938;
				line-height: 100upx;
				text-align: center;
				font-size: 28upx;
				font-weight: bold;
				color: rgba(255, 255, 255, 1);
				right: 0upx;
			}
		}

		.topType {
			display: flex;
			height: 100upx;
			align-items: center;
			width: 100%;
			border-bottom: 1upx rgba(204, 204, 204, 0.3) solid;

			.sel {
				color: rgba(35, 52, 91, 1) !important;
				font-weight: bold !important;
			}

			.item {
				position: relative;
				width: 50%;
				text-align: center;
				font-size: 28upx;
				color: rgba(35, 52, 91, 0.5);
				font-weight: 400;
				height: 100rpx;
				line-height: 100rpx;

				text {
					position: relative;
					z-index: 5;
				}

				.heng {
					width: 72upx;
					height: 8upx;
					background: rgba(251, 202, 63, 1);
					position: absolute;
					bottom: 3upx;
					left: 150upx;
					z-index: 0;
				}
			}
		}

		.top {
			position: relative;

			.noaddress {
				height: 190upx;
				width: 100%;
				display: flex;
				justify-content: center;
				align-items: center;

				image {
					width: 40upx;
				}

				text {
					font-size: 32upx;
					font-weight: bold;
					color: rgba(235, 89, 56, 1);
					margin-left: 10upx;
				}
			}

			.address {
				display: flex;
				position: relative;
				padding: 53upx 70upx;
				font-size: 28upx;
				font-weight: bold;
				align-items: center;

				image {
					position: absolute;
					left: 30upx;
					width: 31upx;
					height: 37upx;
					top: 120upx;
				}

				.txt {
					display: flex;
					justify-content: space-between;
					padding-bottom: 28upx;
				}

				.jt {
					position: absolute;
					right: 30upx;
					top: 105upx;
					content: '';
					border: 1upx solid rgba(57, 72, 107, 0.5);
					border-width: 0 3upx 3upx 0;
					padding: 6upx;
					transform: rotate(-45deg);
					-webkit-transform: rotate(-45deg);
				}
			}
            .pickup {
                padding: 20rpx;
                border-bottom: 1rpx solid #ccc;
                display: flex;
                position: relative;
                font-size: 28rpx;
                font-weight: bold;
                align-items: center;
                
                .txt {
                	display: flex;
                	justify-content: space-between;
                	padding-bottom: 28upx;
                }
                
                .jt {
                	position: absolute;
                	right: 30upx;
                	top: 105upx;
                	content: '';
                	border: 1upx solid rgba(57, 72, 107, 0.5);
                	border-width: 0 3upx 3upx 0;
                	padding: 6upx;
                	transform: rotate(-45deg);
                	-webkit-transform: rotate(-45deg);
                }
            }
			.img {
				position: absolute;
				bottom: 0;
				height: 10upx;
				width: 100%;
			}
		}

		.main {
            border: 6rpx solid #aaa;
            border-radius: 20rpx;
            margin: 20rpx 5rpx;
            
			.goods_top {
				display: flex;
				padding: 20rpx 30rpx 20rpx;
				box-sizing: border-box;
				justify-content: space-between;
				align-items: center;
                border-bottom: 1rpx solid #ccc;

				.left {
					font-size: 32upx;
                    font-weight: 600upx;
					display: flex;
					align-items: center;
					color: #333333;

					image {
						width: 40upx;
						height: 35upx;
						margin-right: 13upx;
					}

					text {
						position: relative;
						padding-right: 30upx;
					}

				}

				.right {
					font-size: 32upx;
					display: flex;
					align-items: center;

					image {
						width: 27upx;
						height: 33upx;
						margin-right: 20upx;
					}


				}
			}

			.goods {
				box-sizing: border-box;
				display: flex;
				align-items: center;
				padding: 20upx 10upx;
				border-bottom: 1upx rgba(235, 236, 240, 1) solid;

				image {
					width: 170upx;
					height: 170upx;
					margin-right: 20upx;
				}

				.right {
					position: relative;
					width: calc(100% - 190upx);
					display: flex;
					flex-direction: column;
					height: 170upx;

					.size {
						display: flex;
						justify-content: space-between;
						font-size: 32upx;
						align-items: center;
					}

					.right-p {
                        font-size: 32rpx;
						-webkit-line-clamp: 2;
						overflow: hidden;
						word-break: break-all;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
					}

					text:first-child {
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 30upx;
					}

					.pic1 {
						font-size: 36upx;
						color: #FF5F60;
						font-weight: bold;
					}
				}
			}

		}

		.line {
			position: relative;
			box-sizing: border-box;
			padding: 37upx 30upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
            flex-wrap: wrap;
			font-size: 28upx;
			color: #666666;
			border-bottom: 1upx rgba(235, 236, 240, 1) solid;

			text:last-child {
				color: #EB5938;
				font-size: 32upx;
			}

			.jt {
				position: absolute;
				right: 10upx;
				top: 49upx;
				content: '';
				border: 1upx solid #CCCCCC;
				border-width: 0 3upx 3upx 0;
				padding: 6upx;
				transform: rotate(-45deg);
				-webkit-transform: rotate(-45deg);
			}

		}

		.pic {
			box-sizing: border-box;
			padding: 37upx 30upx;
			display: flex;
			justify-content: flex-end;
			font-size: 20upx;
			color: rgba(60, 72, 104, 1);
			border-bottom: 1upx rgba(235, 236, 240, 1) solid;

			text:last-child {
				color: rgba(255, 198, 0, 1);
				font-size: 28upx;
			}

			;
		}
        .privilege {
            padding: 20rpx;
            border-bottom: 1rpx solid #eaeaea;
            margin-bottom: 100rpx;
            .checkNpm {
                display: flex;
                justify-content: space-between;
            }
        }
		.common {
			box-sizing: border-box;
			padding: 37upx 30upx;
			display: flex;
			flex-direction: column;
			flex-wrap: wrap;
			align-items: flex-start;
			// font-weight: bold;
			font-size: 28upx;
			color: #666666;

			textarea {
				position: relative;
				font-size: 28upx;
				margin-top: 34upx;
				padding: 24upx 28upx;
				height: 92upx;
				background: rgba(252, 252, 253, 1);
				border-radius: 12upx;
				z-index: 0;
			}
		}

		.pay_type {
			position: relative;
			width: 100%;
			background: #FFFFFF;
			padding-bottom: 140upx;
			height: 60vh;

			text {
				font-size: 42rpx;
			}

			.close {
				position: absolute;
				width: 50upx;
				height: 50upx;
				right: 40upx;
				top: 30upx;
			}

			.title {
				width: 100%;
				text-align: center;
				height: 100upx;
				line-height: 100upx;
				font-size: 36upx;
				border-bottom: 1upx rgba(251, 251, 253, 1) solid;
			}

			.paypir {
				display: flex;
				justify-content: center;
				flex-direction: column;
				align-items: center;
				// padding: 20upx 0upx 20upx;
				font-size: 28upx;

				text:last-child {
					color: #FF5F60;
					font-size: 50upx;
					font-weight: bold;
					margin-top: 10upx;
				}
			}

			.line2 {
				width: 100%;
				box-sizing: border-box;
				padding: 36upx;
				display: flex;
				justify-content: space-between;
				font-size: 28upx;
				color: #333333;
				border-bottom: 1upx rgba(251, 251, 253, 1) solid;
                .nosel {
                    width: 36upx;
                    height: 36upx;
                    border: 1upx solid rgba(60, 72, 104, 1);
                    border-radius: 50%;
                    margin-right: 20rpx;
                }
                
                .sel {
                    background-image: url(../../static/img/check.png);
                    background-repeat: no-repeat;
                    width: 40upx;
                    height: 40upx;
                    background-size: 100%;
                    margin-right: 20rpx;
                }
				.txt {
					color: #999999;
				}

			}

			.pay_bot {
				width: 100%;
				position: fixed;
				left: 0;
				bottom: 0;
				height: 100upx;
				background: #FFBF0A;
				color: #fff;
				font-size: 32upx;
				line-height: 100upx;
				text-align: center;
				border-radius: 0;

				&::after {
					border: none;
				}
			}
		}

        .noRadio {
            width: 36upx;
            height: 36upx;
            border: 1upx solid rgba(60, 72, 104, 1);
            border-radius: 50%;
            margin-right: 20rpx;
        }

        .selRadio {
            background-image: url(../../static/img/check.png);
            background-repeat: no-repeat;
            width: 40upx;
            height: 40upx;
            background-size: 100%;
            margin-right: 20rpx;
        }
		.nocheck {
			width: 36upx;
			height: 36upx;
			border: 1upx solid rgba(60, 72, 104, 1);
			border-radius: 20%;
		}

		.check {
			background: url(../../static/img/checkbox_check.png);
			background-repeat: no-repeat;
			width: 40upx;
			height: 40upx;
			background-size: 100%;
		}

		.popbox {
			width: calc(100% - 100upx);
			height: 650upx;
			margin: 0 30upx;
			padding: 20upx;
			//overflow: hidden;
			position: relative;
			//border: 3upx #fff solid;
			border-radius: 20upx;
			background: rgba(#fff, 1);


			.close {
				position: absolute;
				width: 50upx;
				height: 50upx;
				right: 40upx;
				top: 30upx;
			}

			.title {
				width: 100%;
				text-align: center;
				height: 100upx;
				line-height: 100upx;
				font-size: 32upx;
				border-bottom: 1upx rgba(251, 251, 253, 1) solid;
			}


			.line2 {
				height: 400upx;
				padding: 20rpx;
				color: #222C3E;
				font-size: 24upx;
				text-align: center;

				view {
					padding-bottom: 10rpx;
				}
				.con2-qrc {
					width: 400rpx;
					height: 400rpx;
				}
			}

		}

		.receive_bot {
			width: calc(100% - 200upx);
			height: 100upx;
			margin: 20upx 100upx;
			color: #fff;
			font-size: 32upx;
			line-height: 100upx;
			text-align: center;
			border: 3upx #ffdd00;
			border-radius: 50upx;
			background-color: #FFCC00;

			&::after {
				border: none;
			}
		}

		.receive_ok {
			background: rgba(255, 200, 10, 1);
		}
        .tipTxt {
            width: 100%;
            padding-top: 10rpx;
            padding-left: 55rpx;
        }
	}
</style>
